local addon, db = ...

db.OnInit(function ()
	LoadAddOn"LibItemBonus-2.0"
	local ibl = LibStub"LibItemBonus-2.0"
	local dataobj = LibStub"LibDataBroker-1.1":NewDataObject("JerryItemBonus", {
		type = "data source",
		value = "-",
		suffix = "STA",
	})
	dataobj.OnTooltipShow = function (self)
		local eq = ibl:GetUnitEquipment("player")
		details = ibl:BuildBonusSet(eq)
		bonuses = ibl:MergeDetails(details)
		for bonus in pairs(bonuses) do
			local type, value = ibl:GetFriendlyBonus(bonus, bonuses)
			if math.floor(value) ~= value then
				value = string.format("%.1f", value)
			end
			self:AddDoubleLine(ibl:GetBonusFriendlyName(type), value)
		end
	end
	ibl:RegisterCallback("ItemBonusLib_Update", function()
		dataobj.value = ibl:GetBonus"STA"
	end)
end)
